package main

import "errors"

func test() {
	defer func() {
		err := recover()
		if err != nil {
			println("test1", err)
		}
	}()

	res := 10 / 0
	println(res)
}

func test2() {
	if err := recover(); err != nil {
		println("test2", err)
	}

	res := 10 / 0
	println(res)
}

func main() {
	test()
	test2()

	if err := aaa(); err != nil {
		panic(err)
	}
}

func aaa() (err error) {
	return errors.New("这是自定义错误")
}
